<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<link rel="stylesheet" href="${initParam.root}css/table.css" type="text/css">
<link rel="stylesheet" href="${initParam.root}css/button.css" type="text/css">
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	var flag=$("#regiForm :input[name=flag]").val();
	var flag2=$("#regiForm :input[name=customerEmail]").val();
	
	$("#regiForm").submit(function(){ 
		if(flag==1){
			alert("아이디 중복 체크를 해야합니다.");
			return false;
		}
		if(flag2==1){
			alert("이메일 중복 체크를 해야합니다.");
			return false;
		}
		if($("#regiForm :input[name=passwordCheck]").val()!=$("#regiForm :input[name=customerPassword]").val()){
			alert("비밀번호 확인하시오");
			return false;
		}
	}); //submit
	$("#regiForm :input[name=customerId]").keyup(function(){
		var key= $(this).val();
		$.ajax({
			type : "post",   
			url : "cIdcheck.do",   
			dataType:"json",  
			 data: "customerId="+$(this).val(),
			success : function(jsonData) {
				if(jsonData==1){
					$("#idcheckView").html("아이디가 중복됩니다.");
					flag=1;
					return false;
				}else{
					$("#idcheckView").html("사용가능합니다.");
					flag=0;
				}
			}//success
		});//ajax
	});//keyup
	$("#regiForm :input[name=customerEmail]").keyup(function(){
		var key1= $(this).val();
		$.ajax({
			type : "post",   
			url : "cEmailcheck.do",   
			dataType:"json",  
			 data: "customerEmail="+$(this).val(),
			success : function(jsonData) {
				if(jsonData==1){
					$("#emailcheckView").html("이메일이 중복됩니다.");
					flag2=1;
				}else{
					$("#emailcheckView").html("사용가능합니다.");
					flag2=0;
				}
			}//success
		});//ajax
	});//keyup

	$("#regiForm").submit(function(){
		if(flag2==1){
			alert("이메일 중복 체크를 해야합니다.");
			return false;
		}
	});
});
</script>
<form method="post" id="regiForm" action="customer_register.do">
<input type="hidden" name="flag" value="">
<table  border="1" class="registerMemberTable"  style="margin: 0 auto ; width: 500px" >
<tr style="height: 80px;">
	<td colspan="2" style="font-size: 36px">구매자 회원가입</td>
</tr>
<tr>
<tr>
	<td>아이디</td><td><span id="idcheckView"></span><br><input type="text" name="customerId"required autofocus></td>
</tr>
<tr>
	<td>비밀번호</td><td><input type="password" name="customerPassword"required></td>
</tr>
<tr>
<td>비밀번호확인</td><td><input type="password" name="passwordCheck" required></td>
</tr>
<tr>
	<td>이메일</td><td><span id="emailcheckView"></span><br><input type="email" name="customerEmail" required></td>
</tr>
<tr>
	<td>이름</td><td><input type="text" name="customerName"required></td>
</tr>
<tr>
	<td>생년월일</td><td><input type="date" min="1900-01-01" max="2014-12-31" name="customerBirthdate"required></td>
</tr>
<tr>
	<td>성별</td><td><input type="radio" name="customerGender" value="남자" checked="checked">남자
								<input type="radio" name="customerGender" value="여자">여자</td>
</tr>
<tr>
	<td>전화번호</td><td><input type="text" name="customerTel"required="required" pattern="\d+">
	</td>
</tr>
<tr>
	<td>주소</td><td><input type="text" name="customerAddress"required></td>
</tr>
<tr>
	<td colspan="2"><input type="submit" value="회원가입" class="submit">	
</td>
</table>
</form> 
